package cn.iocoder.yudao.module.xhyy.dal.mysql.knowledge;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.xhyy.controller.app.knowledge.vo.AppKnowledgePageReqVO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.knowledge.KnowledgeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.xhyy.controller.admin.knowledge.vo.*;

/**
 * 知识点 Mapper
 *
 * @author duanxinli
 */
@Mapper
public interface KnowledgeMapper extends BaseMapperX<KnowledgeDO> {

    default PageResult<KnowledgeDO> selectPage(KnowledgePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeDO>()
                .likeIfPresent(KnowledgeDO::getKnowName, reqVO.getKnowName())
                .eqIfPresent(KnowledgeDO::getChapter, reqVO.getChapter())
                .eqIfPresent(KnowledgeDO::getGrade, reqVO.getGrade())
                .likeIfPresent(KnowledgeDO::getBookName, reqVO.getBookName())
                .eqIfPresent(KnowledgeDO::getKnowUrl, reqVO.getKnowUrl())
                .orderByAsc(KnowledgeDO::getGrade)
                .orderByAsc(KnowledgeDO::getChapter));
    }

    default PageResult<KnowledgeDO> selectPage(AppKnowledgePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeDO>()
                .likeIfPresent(KnowledgeDO::getKnowName, reqVO.getKnowName())
                .eqIfPresent(KnowledgeDO::getChapter, reqVO.getChapter())
                .eqIfPresent(KnowledgeDO::getGrade, reqVO.getGrade())
                .eqIfPresent(KnowledgeDO::getBookId, reqVO.getBookId())
                .eqIfPresent(KnowledgeDO::getKnowUrl, reqVO.getKnowUrl())
                .orderByAsc(KnowledgeDO::getChapter));
    }

}